import { jobGoto } from "./goto";

export const jobUpgrade={
    /**
     * 
     * @param {Creep} creep 
     * @param {Room} room 
     * @param {MoveToOpts} opts
     */
    run(creep, room, opts={}){
        if(room===undefined){
            room=creep.room;
        }
        if(opts.visualizePathStyle==undefined){
            opts.visualizePathStyle={stroke: "#ffffff"}
        }
        let ret;
        let mainRoomName=creep.room.memory.mainRoomName;
        let controller=Game.rooms[mainRoomName].controller;
        ret=creep.upgradeController(controller);
        if(!creep.pos.isNearTo(controller.pos)){
            jobGoto.run(creep, [controller], opts);
            return ERR_NOT_IN_RANGE;
        }
        return ret;
    }
}